const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  mode: 'development',

  plugins: [
    new HtmlWebpackPlugin(),
  ],

  devtool: 'source-map',

  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              [
                '@babel/preset-env',
                {
                  targets: [ // 告诉@babel/preset-env遇到了这样的浏览器需要通过Polyfills使用添加垫片
                    '> 1%',
                    'last 1 version',
                  ],
                  useBuiltIns: 'usage',
                  corejs: 3, // 添加corejs配置
                },
              ],
            ],
            // plugins: ['@babel/plugin-transform-runtime'],
          },
        },
      },
    ],
  },
};
